<template>
  <onez-view class="record" v-if="record.length">
    <template v-for="(item, index) in record" :key="index">
      <onez-view class="item" >
        <onez-view class="link" v-if="item.type == 'link'" @click.native="click(item)">{{ item.text }}</onez-view>
        <onez-view class="pictext2" v-else>
          <onez-view class="left" v-if="item.icon"><onez-view class="icon" :style="'background-image:url(' + item.icon + ');' + item.iconStyle"></onez-view></onez-view>
          <onez-view class="center">
            <onez-view class="subject" v-if="item.subject" :style="item.subjectStyle">{{ item.subject }}</onez-view>
            <onez-view class="summary" v-if="item.summary" :style="item.summaryStyle">{{ item.summary }}</onez-view>
            <onez-view class="btns" :style="item.btnsStyle" v-if="item.btns && item.btns.length">
              <onez-view class="bt" :class="'bt-' + btn.type" v-for="(btn, index2) in item.btns" :key="index2" :type="btn.type" @click.native="click(btn)">
                {{ btn.name }}
              </onez-view>
            </onez-view>
          </onez-view>
          <onez-view class="right">
            <onez-view class="rt" v-if="item.rt">{{ item.rt }}</onez-view>
            <onez-view class="rb" v-if="item.rb">{{ item.rb }}</onez-view>
          </onez-view>
        </onez-view>
      </onez-view>
    </template>
  </onez-view>
</template>

<script>
		import onezView from '../onez-view/onez-view.vue'
export default {
  name: 'onez-record',
  components: {
  	onezView
  },
  data() {
    return {};
  },
  props: {
    record: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  methods: {
    async click(e) {
      if (e.event) {
        let r=await this.$game.onEvent(this, e.event);
        if(!r){
          this.$emit('event',{token:'close'});
        }
      }
    }
  }
};
</script>

<style scoped>
.record {
  margin: 5px 0 0 5px;
}
.record::after {
  content: '';
  display: block;
  clear: both;
}
.record .item {
  display: block;
  margin: 0 0px 10px 0;
}
.record .item .pictext2 {
  display: block;
  border: 1px solid #0f91a9;
  background-color: #2bccda;
  border-radius: 3px;
  padding: 8px;
  white-space: nowrap;
}
.record .item .pictext2 .icon {
  display: block;
  border: 1px solid #0e96ab;

  width: 60px;
  height: 40px;
  background-color: #21dbf3;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center center;
  margin-right: 5px;
}
.record .item .pictext2::after {
  content: '';
  display: block;
  clear: both;
}
.record .item .left {
  display: block;
  float: left;
  position: relative;
}
.record .item .center {
  display: inline-block;
  position: relative;
}
.record .item .subject {
  font-size: 14px;
}
.record .item .summary {
  font-size: 12px;
  line-height: 2;
  word-break: break-all;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.record .item .btns {
  padding: 0;
  text-align: left;
}
.record .item .right {
  display: inline-block;
  float: right;
  position: relative;
}
.record .item .btns .bt {
  border: 1px solid #015e88;
  color: #fff;
  text-align: center;
  padding: 0 3px;
  background: #1cb5cb;
  cursor: pointer;
  display: inline-block;
  margin: 0 5px 5px 0;
  font-size: 12px;
}
.record .item .btns .bt:hover {
  border: 1px solid #015e88;
  background: #0f91a9;
}
.link {
  pointer-events: all;
  color: #adf5ff;
  display: inline-block;
  margin: 5px;
  cursor: pointer;
}
.link:hover {
  color: #2be2fc;
}
</style>
